package com.gitee.center.runtime.def;

import com.gitee.center.runtime.IDomainExtension;
import com.gitee.center.runtime.IDomainModel;
import com.gitee.center.runtime.IIdentityResolver;
import com.gitee.center.runtime.IRegistryAware;
import com.sun.istack.internal.NotNull;

import java.util.HashMap;
import java.util.Map;

public class PatternDef implements IRegistryAware {

    private IIdentityResolver patternBean;

    private Map<Class<? extends IDomainExtension>, ExtensionDef> extensionDefMap = new HashMap<>();

    @Override
    public void registerBean(Object bean) {

    }

    public boolean match(@NotNull IDomainModel model) {
        return patternBean.match(model);
    }

    public ExtensionDef getExtension(Class<? extends IDomainExtension> extClazz) {
        return extensionDefMap.get(extClazz);
    }

    public void registerExtensionDef(ExtensionDef extensionDef) {
        Class<? extends IDomainExtension> extClazz = extensionDef.getExtClazz();
        extensionDefMap.put(extClazz, extensionDef);
    }
}
